<?php

class LoginAction extends Action{
    //微信端工作人员登录
    public function login(){
        $tmplParseString = array();
        $tmplParseString['__STATIC__'] = __APP__ . '/static';
        $tmplParseString['__UPLOAD__'] = __APP__ . '/upload';
        $tmplParseString['__SITE_URL__'] = __APP__;
        C('TMPL_PARSE_STRING', $tmplParseString);
        $this->assign('baseurl', getBaseUrl());
        $this->display();
    }

    //匹配账号密码
    public function checkpwd(){
        import('ORG.Util.Session');
        import('ORG.Util.Cookie');
        $map['mobile'] = trim(I('post.phone'));
        $map['password'] = trim(I('post.password'));
        $exist = M('admin')->where($map)->find();
        if($exist){
            
            $userid = M('wxuser')->where(array('openid'=>session::get('openid')))->getField('id');
            $data['account'] = $map['mobile'];
            $data['pwd'] = $map['password'];
            $data['createtime'] = time() + 12*3600;
            M('login_redirect')->where(array('w_id'=>$userid))->save($data);
            $redirect_modules = M('login_redirect')->where(array('w_id'=>$userid))->find();
            $url = "http://house.wechatpic.com/Mobile/".$redirect_modules['action'].'/'.$redirect_modules['func'];

            $this->ajaxReturn(array('val'=>0,'url'=>$url,'session'=>$_SESSION));
        }else{
            $this->ajaxReturn(array('val'=>1));
        }
    }

}
?>